package com.heima.article;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan(basePackages = "com.heima.article.mapper")
public class ArticleApplication {
    public static void main(String[] args) {

        SpringApplication.run(ArticleApplication.class,args);
    }
    /**
     * MyBatisPlus分页流程
     * 1：创建拦截器 MybatisPlusInterceptor
     * 2：创建分页对象 Ipage
     * 3：执行列表查询，返回Ipage
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor  = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
       return mybatisPlusInterceptor;
    }



}
